#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
const int maxn = 1000100;
const int maxm = maxn * 2;
string s1, s2; // s2 pattern
string cur;
int nxt[maxm]; // cur
int nxt2[maxn]; // s2
void gnext() {
    nxt[0] = 0;
    for (int i = 1; i < cur.length(); i++) {
        int j = nxt[i - 1];
        while (j > 0 && cur[i] != cur[j]) j = nxt[j - 1];
        if (cur[i] == cur[j]) j++;
        nxt[i] = j;
    }
    nxt2[0] = 0;
    for (int i = 1; i < s2.length(); i++) {
        int j = nxt2[i - 1];
        while (j > 0 && s2[i] != s2[j]) j = nxt2[j - 1];
        if (s2[i] == s2[j]) j++;
        nxt2[i] = j;
    }
}
void find() {
    for (int i = s2.length() + 1; i < cur.length(); i++) {
        // cout << i << " " << endl;
        if (nxt[i] == s2.length()) {
            // cout << i << " " << i - s2.length() * 2 + 1 << endl;
            cout << i - s2.length() * 2 + 1 << endl; 
        }
    }
}
void print() {
    // for (int i = 0; i < s1.length(); i++) {
        // cout << nxt[i] << " ";
    // }
    // cout << endl;
    for (int i = 0; i < s2.length(); i++) {
        cout << nxt2[i] << " ";
    }
    cout << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> s1 >> s2;
    cur = s2 + "#" + s1;
    gnext();
    find();
    print();
    return 0;
}
